package com.winit.openapi.oauth.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.winit.common.orm.mybatis.MyBatisPageRepo;
import com.winit.common.orm.mybatis.MyBatisRepo;
import com.winit.common.orm.mybatis.PageBase;
import com.winit.common.query.Searchable;
import com.winit.openapi.oauth.entity.UserAuthorizationEntity;

@MyBatisRepo
public interface UserAuthorizationDao extends MyBatisPageRepo<UserAuthorizationEntity, Long> {

    int insertSelective(UserAuthorizationEntity entity);

    int updateSelective(UserAuthorizationEntity entity);

    List<UserAuthorizationEntity> queryByClientId(Long clientId);
    
    void updateClient(@Param("clientId") Long clientId, @Param("clientName") String clientName);

    void deleteUserByClient(Long clientId);

    int getUserCountByClient(Long clientId);

    UserAuthorizationEntity queryByClientAndUser(@Param("clientId") Long clientId, @Param("userId") Long userId);
    
    UserAuthorizationEntity queryByClientAndUserName(@Param("clientId") Long clientId, @Param("userName") String userName);

    void synUserInfo(@Param("userId") Long userId, @Param("userName") String userName,
                     @Param("companyName") String companyName);
    
    PageBase<UserAuthorizationEntity> find(Searchable searchable);

}
